import { UpdateDto } from "@/common/type/app.dto";
import { PartialType } from "@nestjs/swagger";
import { ArrayNotEmpty, IsArray, IsNotEmpty, IsNumber, IsString } from "class-validator";

export class GateInCntrDto {

    @IsNotEmpty({
        message: '箱号不能空'
    })
    cntr: string;
    @IsNotEmpty({
        message: '箱进场动态不能为空'
    })
    stat_cod: string; 
    @IsNotEmpty({
        message: '计划ID不能为空',
    })
    in_truck_sn: number;

    @IsNotEmpty({
        message: '箱况不能为空'
    })
    dam_id: string;

    cntr_net_wgt: number;
    @IsNotEmpty({
        message: '进场时间不能为空'
    })
    to_port_tim: Date;
    
    bill_no: string;
    cntr_date: Date;
    refmachine_brand: string;
    refmachine_model: string;
    refmachine_date: Date;
    in_ship_nam: string;
    in_voyage: string;
    scale_wgt: number;
    
}
export class GateOutCntrDto {

   /*  @IsNotEmpty({
        message: '箱号不能空'
    })
    cntr: string; */
    @IsArray()
    @IsString(
        {
            each: true,
            message: '箱号类型错误',
        },
    )
    @ArrayNotEmpty({
        message: '箱号不能为空'
    })
    cntrs: string[];

    @IsNotEmpty({
        message: '出场计划ID不能为空',
    })
    out_truck_sn: number;

    @IsNotEmpty({
        message: '离场时间不能为空'
    })
    leav_port_tim: Date;

    // release_no: string;
    out_truck_no_c: string;
    out_truck_tel: string;

}
export class RentInCntrDto {
    @IsNotEmpty({
        message: '箱号不能空'
    })
    cntr: string;
    
    @IsNotEmpty({
        message: '退租计划ID不能为空',
    })
    rent_sn: number;

    @IsNotEmpty({
        message: '箱况不能为空'
    })
    dam_id: string;

    
    @IsNotEmpty({
        message: '退租时间不能为空'
    })
    back_date: Date;

    back_truck_no_c: string;
    back_driver_tel: string;
}
export class CntrFixItemDto {
    @IsNotEmpty({
        message: '箱编号不能空'
    })
    cntr_no: number;

    @IsNotEmpty({
        message: '修理项目不能空'
    })
    fix_item_nam: string;

    @IsNotEmpty({
        message: '修理金额不能空'
    })
    total_money: number;
}

export class UpdateCntrFixItemDto extends PartialType(CntrFixItemDto) implements UpdateDto {
    @IsNumber(
        {},
        {
            message: '缺少id',
        },
    )
    id: number;
}

export class DeleteCntrFixItemsDto {
    @IsArray({
        message: 'ids参数类型错误',
    })
    @ArrayNotEmpty({
        message: 'ids参数不能为空',
    })
    @IsNumber(
        {},
        {
            each: true,
            message: 'ids参数类型错误',
        },
    )
    ids: number[];

    @IsNotEmpty({
        message: '箱编号不能为空'
    })
    cntr_no: number;
}